<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title>制作12进制的时钟特效</title>
		<script>
			function clock_time(){
				var time=new Date();
				var year=time.getFullYear();
				var month=time.getMonth()+1;
				var date=time.getDate();
				var hour=time.getHours();
				var minute=time.getMinutes();
				var second=time.getSeconds();
				
				var apm="AM";
				if(hour>12){
					hour=hour-12;
					apm="pm";
				}
				var weekday=0;
				switch(time.getDay()){
				            case 0:
				                weekday = "星期日";
				                break;
				            case 1:
				                weekday = "星期一";
				                break;
				            case 2:
				                weekday = "星期二";
				                break;
				            case 3:
				                weekday = "星期三";
				                break;
				            case 4:
				                weekday = "星期四";
				                break;
				            case 5:
				                weekday = "星期五";
				                break;
				            case 6:
				                weekday = "星期六";
				                break;
				        }
				
				        /*设置div的内容为当前时间*/
				        document.getElementById("myclock").innerHTML="<h2>你好，欢迎访问贵美商城！</h2><h2>"+year+"年"+month+"月"+date+"日&nbsp;"+hour+":"+minute+":"+second+
						"&nbsp;"+apm+"&nbsp;"+weekday+"</h2>";
			}
			var myTime = setInterval("clock_time()",1000);
		</script>
	</head>
	<body>
		<div id="myclock"></div>
	</body>
</html>
